package com.wlz.thread;

import com.wlz.service.IVoteAccessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 *  添加uininId
 * @Author wlz
 * @Date 2019-11-18 13:48
 */
@Component
public class AsyncSendGZHMessage {

    private Logger logger = LoggerFactory.getLogger(AsyncSendGZHMessage.class);


    @Autowired
    private IVoteAccessService voteAccessService;

//    @Resource
//    private AppUserMapper appUserMapper;

    /**
     *      邀请好友投票成功  发送模板消息
     * @param applyUserId  发送人 用户id
     * @param userId        投票人用户id
     */
    @Async
    public void voteAccessMessage(Integer applyUserId , Integer userId,Integer applyId){

        logger.info("voteAccessMessage start.......");
//        if (applyUserId != null && userId != null) {
//            // 根据用户id 查询 用户 unionId
//            String unionId =  appUserMapper.getUserUnionId(applyUserId);
//            if (null != unionId && !"".equals(unionId)) {
//                // 根据用户 unionId 获取 公众号 openId
//                String openId = appUserMapper.getOpenIdByUnionId(unionId);
//                if (null != openId && !"".equals(openId)) {
//                    logger.info("openId :"+ openId);
//                    // 获取用户
//                    AppUserDemand userDemand = appUserMapper.getUserInfo(userId);
//                    if (userDemand != null) {
//                        voteAccessService.runReport(openId,userDemand.getNickName(),userDemand.getPhone(),applyId);
//                    }
//                }
//            }
//        }

        logger.info("voteAccessMessage end.......");
    }

}
